package vsm.vsm_server.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vsm.vsm_server.mapper.RelationMapper;
import vsm.vsm_server.service.ActionService;
import vsm.vsm_server.service.RelationService;

import java.math.BigInteger;
import java.util.List;


@Service
public class RelationServiceImpl implements RelationService {
    private RelationMapper relationMapper;

    @Autowired
    ActionService actionService;
    public RelationServiceImpl(RelationMapper relationMapper) {this.relationMapper=relationMapper;}


    @Override
    public Integer isFollow(BigInteger userid, BigInteger followid) {
        return  relationMapper.isFollow(userid,followid);
    }

    @Override
    public Boolean follow(BigInteger userid, BigInteger followid,Integer relation) {


        //记录关注
        actionService.SubscribeUser(userid,followid, relation);
        return relationMapper.follow(userid,followid,relation);
    }

    @Override
    public Boolean delete(BigInteger userid, BigInteger followid) {
        return relationMapper.delete(userid,followid);
    }

    @Override
    public Boolean update(BigInteger userid, BigInteger followid,Integer relation) {
        return relationMapper.update(userid,followid,relation);
    }

    @Override
    public List<BigInteger> getSubs(BigInteger userid) {
        return relationMapper.getSubs(userid);
    }

    @Override
    public List<BigInteger> getFans(BigInteger followid) {
        return relationMapper.getFans(followid);
    }
}
